﻿using System;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Serverless.Cf;

namespace Example
{
    public class Hello
    {
        // public HTTPTriggerResponse Handler0(HTTPTriggerEvent input)
        // {
        //     var str = JsonSerializer.Serialize(input);

        //     // 控制台打印
        //     Console.WriteLine("Hello console: " + str);

        //     return new HTTPTriggerResponse
        //     {
        //         StatusCode = 200,
        //         IsBase64Encoded = false,
        //         Body = str
        //     };
        // }

        public HTTPTriggerResponse Handler(HTTPTriggerEvent input, ICfContext context)
        {
            var str = JsonSerializer.Serialize(input);

            // 控制台打印
            Console.WriteLine("Hello console: " + str);
            // 日志打印
            context.Logger.LogInformation("Hello log: " + str);

            return new HTTPTriggerResponse
            {
                StatusCode = 200,
                IsBase64Encoded = false,
                Body = str
            };
        }

        static void Main(string[] args) { }
    }
}